#============================================================
#	Dictionary Util
#============================================================
#  字典工具
#============================================================
# @datetime: 2022-5-6 00:15:31
#============================================================
class_name DictionaryUtil



##  返回排除了对应 key 的字典
## @data  
## @_exclude_key  
## @return  
static func exclude_key(data: Dictionary, _exclude_key: Array) -> Dictionary:
	var temp = {}
	for key in data:
		if not key in _exclude_key:
			temp[key] = data[key]
	return temp


static func find_data(data_list: Array, data: Dictionary, _exclude_key: Array) -> Dictionary:
	var data_hash : int = exclude_key(data, _exclude_key).hash()
	for d in data_list:
		if data_hash == exclude_key(d, _exclude_key).hash():
			return d
	return {}


static func find_all_data(data_list: Array, data: Dictionary, _exclude_key: Array) -> Array:
	var list = []
	var data_hash : int = exclude_key(data, _exclude_key).hash()
	for d in data_list:
		if data_hash == exclude_key(d, _exclude_key).hash():
			list.append(d)
	return list


